<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>登录 | 传媒人后台管理系统</title>
<?= HTML::style('static/bootstrap-3.3.7/css/bootstrap.min.css')?>
<?= HTML::style('static/sweetalert/sweetalert.css')?>
<style>
body {
	padding-top: 50px;
	padding-bottom: 40px;
	background-color: #e6e6e6;
}
.form-signin {
	padding: 15px;
	margin: 0 auto;
}
.form-signin .form-signin-heading,.form-signin .checkbox {
	margin-bottom: 10px;
}
.form-signin .checkbox {
	font-weight: normal;
}
.form-signin .form-control {
	position: relative;
	height: auto;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	padding: 10px;
	font-size: 16px;
}
.form-signin .form-control:focus {
	z-index: 2;
}
.form-signin input[type="text"] {
	margin-bottom: -1px;
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
	margin-bottom: 10px;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}
</style>
</head>
<body>
<div class="container" style="max-width: 380px;">
<div class="panel panel-default">
  <div class="panel-heading">登录 | 传媒人后台管理系统</div>
  <div class="panel-body">
	<form class="form-signin ajax-submit" action="" method="post">
		<input type="hidden" name="csrf" value="<?= Security::token()?>"> 
		<input type="text" name="username" class="form-control" placeholder="用户名" required>
		<input type="password" name="password" class="form-control" placeholder="密码" required>
		<button class="btn btn-lg btn-default btn-block" type="submit">登录</button>
	</form>
  </div>
</div>
</div>
<?= HTML::script('static/js/jquery-1.12.4.min.js')?>
<?= HTML::script('static/sweetalert/sweetalert.min.js')?>
<script>
$(document).on('submit', '.ajax-submit', function() {
	var t = $(this);
	var url = t.attr('action') || location.href;
	var type = t.attr('method');
	$.ajax({
        type: type,
        url: url,
        data: t.serialize(),
        success: function(res) {
    		//console.log(res);
    		if (res.errno != 0) {
        		//alert(res.errmsg);
        		swal({title: "", text: res.errmsg, type:"error"}, function(){
        			  location.reload(); 
        		});
    		} else {
        		location.href = res.data;
    		}
        }
	}); 
	return false;
});
</script>
</body>
</html>
